package kr.hkit.powerjava.chther24;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class CopyfileReader {
	public static void main(String[] args) {
		BufferedReader fr = null;
		BufferedWriter fw = null;
		PrintWriter pw =null;
		
		try {
			fr = new BufferedReader(new FileReader("input.txt"));
			fw = new BufferedWriter( new FileWriter("output2.txt"));
			pw = new PrintWriter("output2.txt");
			String line;
			while((line= fr.readLine())!=null){
//				fw.write(line+"\n");
				pw.println(line);
			}
			/*int c;
			while((c=fr.read()) != -1){
				System.out.format("%s",(char)c);
				fw.write(c);
			}*/
		} catch (FileNotFoundException e) {
			System.err.format("%s%n", "파일이 존재하지 않음");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if(fr != null){
				try{fr.close();}catch(Exception e){}
			}
			if(fw != null){
				try{fw.close();}catch(Exception e){}
			}
			if(pw != null){
				try{pw.close();}catch(Exception e){}
			}
		}
	}
}
